<template>
	
	<form @submit="submit" :data-action="`/api/comsumablesRepalce/save?stationId=${param.id}`">
			
			<view class="father">
				<view class="fixAuto bb middle">
					<view class="w100">
						设备名称
					</view>
					<view class="text-right">
						{{factorList[factorIndex]}}
						<text class="ml5 sIcon-arrowRight grey"></text>
					</view>
				</view>
				<picker class="op0 abs" mode="selector" :range="factorList" :value="factorIndex" @change="changeFactor">
					<view class="op0 abs">{{factor}}</view>
				</picker>
			</view>
			<view class="fixAuto bb middle" v-show="isOtherFator">
				<view class="w100">
					其他设备名称
				</view>
				<view>
					<input type="text" name="x.deviceName|设备名称|0~200" :value="factor" placeholder="请输入设备名称">
				</view>
			</view>
			
			
			<view class="fixAuto bb middle">
				<view class="w100">
					易耗品名称
				</view>
				<view>
					<input type="text" name="x.comsumablesName|易耗品名称|0~200" placeholder="请输入易耗品名称">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					数量
				</view>
				<view>
					<input type="number" name="x.count|数量|amount" placeholder="请输入数量">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					单位
				</view>
				<view>
					<input type="text" name="x.unit|单位|0~20" placeholder="请输入单位">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					更换说明
				</view>
				<view>
					<input type="text" name="x.remark|更换说明|0~200" placeholder="请输入更换说明">
				</view>
			</view>
			
			<view class="plr100 pd30">
				<button form-type="submit" class="btn block rds23">
					保存记录
				</button>
			</view>
		</form>

	</layout>
</template>

<script>
	export default {
		data() {
			return {
				param:{id:"",type:1} ,
				factorList:["二氧化硫分析仪","氮氧化物分析仪","氧气分析仪","一氧化碳分析仪","氯化氢分析仪","氟化物分析仪","温度计","压力计","流速仪","湿度仪","其他"],
				factorIndex:0,
				factor:"二氧化硫分析仪"
			}
		},
		computed:{
			isOtherFator : function(e){
				return this.factorList[this.factorIndex] == '其他' ;
			}
		},
		onLoad(params) {
			this.param = params ;
			if(params.type == 1){
				this.factorList = ["COD分析仪","PH分析仪","氨氮分析仪","总磷分析仪","总氮分析仪","流量计","其他"];
			}
		},
		methods: {
			
			changeFactor:function(e){
				this.factorIndex = e.detail.value ;
				var factor = this.factorList[this.factorIndex] ;
				this.factor = factor == '其他' ? '' : factor ;
			},
			
			submit:function(e){
				this.form.submit(e , this.success);
			},
			
			success:function(e){
				this.kit.goSuccessBack("保存成功");
			}
		}
	}
</script>
<style>
	page{
		background-color: #fff;
	}
</style>